class Api::V1::SchoolStaffController < ApplicationController
  before_action :authenticate
  
  
  def index
	sId = getSessionId
	studentId = params["studentId"]
	
	childSchool = Child.select( "schools.id as idSchool" )
					.where( :phone_users => { api_key: sId } , :children => {id: studentId} )
					.joins( :phone_users , :schools ).first or not_found
	
	idSchool = childSchool.idSchool
	staffList = SchoolStaff.select("nameToShow as name,rol as area,phonenumber,email")
				.joins( :school )
				.where( :schools => {id:idSchool} )
	
	result = Hash.new
	
	staffList.each do |s|
		if result[s.area].nil? 
			result[s.area] = Array.new
		end
		result[s.area].push( s )
	end
	
	render :json => result
  end
end